<?php 
require_once ROOT_PATH . '/lib/models/hrfunct/EmpInfo.php';
$empList = EmpInfo::getEmpSkillInfo();
$baseURL = './CentralController.php?skillMatrixcode=SkillMatrix';
?>
<script type="text/javascript">

function showhide(link, row) {
    if (link.className == 'expanded') {
        link.className = 'collapsed';
        $('details_' + row).style.display = 'none';
        $('expertisedetails_' + row).style.display = 'none';        
        //$('summary_' + row).style.display = 'block';
    } else {
        link.className = 'expanded';
        $('details_' + row).style.display = 'block';
        $('expertisedetails_' + row).style.display = 'block';
        //$('summary_' + row).style.display = 'none';
    }
}

 function returnAdd() {
		location.href = '<?php echo $baseURL;?>&action=AddGroup';
}

 function returnDelete(id) {
 	var flag=confirm("Are you sure you would like to delete this record?");				
				if(flag){
					location.href = '<?php echo $baseURL;?>&action=DeleteSkillGroup&id='+id;
				}else{
					return false;
				}
	
}

function saveOrder(){
	document.frmGroupSkills.submit();
	
}

function isNumeric(elem, helperMsg){
	var numericExpression = /^\s*(\+|-)?((\d+(\.\d+)?)|(\.\d+))\s*$/;

	if(elem.value.match(numericExpression)){
		return true;
	}else{
		alert(elem.value +" is " + helperMsg);
		elem.focus();
		return false;
	}
}

</script>
<h2><?php echo "Group Skills"; ?><hr/></h2>
<?php if (isset($_GET['message'])) {

		$expString  = $_GET['message'];
?>
		<font size="-1" face="Verdana, Arial, Helvetica, sans-serif">
<?php echo $expString; ?>
		</font>
<?php }	?>
<form id="frmGroupSkills" name="frmGroupSkills" method="post" action="<?php echo $baseURL;?>&action=UpdateOrder">
<div style="padding: 6px;">
				<img 
					title="Add" 
					alt="Add"
					src="../../themes/beyondT/pictures/btn_add.gif" 
					style="border: none;"
					onclick="returnAdd();"
					onmouseout="this.src='../../themes/beyondT/pictures/btn_add.gif';" 
					onmouseover="this.src='../../themes/beyondT/pictures/btn_add_02.gif';" />						
</div>
<table border="0" cellpadding="0" cellspacing="0" width="600">
   <thead>
  	<tr>
		<th class="tableTopLeft"></th>    	
    	<th class="tableTopMiddle" ></th>
    	<th class="tableTopMiddle" ></th>
    	<th class="tableTopMiddle" ></th>
		<th class="tableTopRight"></th>
	</tr>
	
	<tr>
		<th class="tableMiddleLeft"></th>		
    	<th class="tableMiddleMiddle"  ><?php echo "Group"; ?></th>
    	<th class="tableMiddleMiddle"   ><?php echo "Action"; ?></th>
    	<th class="tableMiddleMiddle"   ><?php echo "Order"; ?><img 
					title="Save order" 
					alt="Save order"
					src="../../themes/beyondT/pictures/filesave.png" 
					style="border: none;"
					onclick="saveOrder();"
					></th>
		<th class="tableMiddleRight"></th>
	</tr>
  </thead>
  <tbody>
 <?php if (is_array($records) && count($records)>0) { 
  	for($m=0;$m<count($records);$m++) {
  		$record = $records[$m];
  		$skillExpertises = $record->getSkillExpertise($record->getId());
  		
  	?>
  <tr>
  	<td class="tableMiddleLeft"></td>
  	<td>
  		<a href="#" class="collapsed" id="link_<?php echo $record->getId();?>" onclick="showhide(this, <?php echo $record->getId();?>)" ><?php echo $record->getSkillGroupName(); ?> </a>
  		<?php // echo '<a href="CentralController.php?skillMatrixcode=SkillMatrix&action=ShowEditSkillGroup&id='.$record->getId().'" target="rightMenu">'.$record->getSkillGroupName().'</a></td>'; ?>
  		<br/>
  		<table cellpadding="0" cellspacing="0" id="details_<?php echo $record->getId();?>" style="text-decoration:none;display:none;">
  			<?php if(count($skillExpertises)>0){
  			 foreach($skillExpertises as $skillExpertise){ ?>
  			<tr>
  				<td>
  					<?php echo $skillExpertise->getSkillExpertiseName(); ?>
  				</td>
  			</tr>
  			<?php }
  			} ?>
  		</table>
  	</td>
  	<td>
  		<a href="CentralController.php?skillMatrixcode=SkillMatrix&action=ShowEditSkillGroup&id=<?php echo $record->getId();?>" target="rightMenu">Edit</a>|<a href="#" onclick="returnDelete(<?php echo $record->getId();?>)" target="rightMenu">Delete</a>
  		
  	</td>
  	<td>
  		<input type="text" size="2" name="<?php echo "order".$record->getId();  ?>" name="<?php echo "order".$record->getId();  ?>" value="<?php echo $record->getSkillGroupOrder(); ?>" onchange="isNumeric(this,'invalid');"  >
  		<br/>
  		<table cellpadding="0" cellspacing="0" id="expertisedetails_<?php echo $record->getId();?>" style="text-decoration:none;display:none;">
  			<?php if(count($skillExpertises)>0){
  			 foreach($skillExpertises as $skillExpertise){ ?>
  			<tr>
  				<td style="padding: 1px;">
  					<input type="text" size="2" name="<?php echo "order".$record->getId()."exp".$skillExpertise->getId();  ?>" name="<?php echo "order".$record->getId()."exp".$skillExpertise->getId();  ?>" value="<?php echo $skillExpertise->getSkillExpertiseOrder(); ?>" onchange="isNumeric(this,'invalid');"  >
  				</td>
  			</tr>
  			<?php }
  			} ?>
  		</table>
  	</td>
  	
  	<td class="tableMiddleRight"></td>
  </tr>
  <?php }
  	
 } ?>
  				
  </tbody>
 
  <tfoot>
  	<tr>
		<td class="tableBottomLeft"></td>
		<td class="tableBottomMiddle"></td>
		<td class="tableBottomMiddle"></td>
		<td class="tableBottomMiddle"></td>
		<td class="tableBottomRight"></td>
	</tr>
  </tfoot>
  
</table>

